using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using ViCode_LeVi.Controls.Charts;
using ViCode_LeVi.Data;
using ViCode_LeVi.Controls.Logs;

namespace ViCode_LeVi.Controls.Reports
{
    public partial class BarChartQQSSubReport : DevExpress.XtraReports.UI.XtraReport
    {
        private string m_sInterpretation = string.Empty;
        public BarChartQQSSubReport()
        {
            InitializeComponent();
        }
        public bool CreateReport(BarChartQQS oChartCtrl, ref int riNumberOfElements)
        {
            bool flag = true;
            try
            {
                var oWorkingProject = RootData.Intance;
                if (oChartCtrl != null)
                {
                    this.m_oChartCtrl1.ChartLabelMode = oChartCtrl.ChartLabelMode;
                    this.m_oChartCtrl1.LabelWithPercent = oChartCtrl.LabelWithPercent;
                    this.m_oChartCtrl1.ChartLegendMode = oChartCtrl.ChartLegendMode;
                    this.m_oChartCtrl1.LegendWithPercent = oChartCtrl.LegendWithPercent;
                    this.m_oChartCtrl1.ChartBackColor = Color.White;
                    this.m_oChartCtrl1.Func_GetStep_TaskItemGroup = oChartCtrl.Func_GetStep_TaskItemGroup;
                }
                else
                {
                    //this.m_oChartCtrl1.ReadOptions(oWorkingProject);
                }
                this.m_oChartCtrl1.FilterFactorTypeBK = false;
                this.m_oChartCtrl1.FilterFactorTypeHK = false;
                this.m_oChartCtrl1.FilterFactorTypeSK = false;
                this.m_oChartCtrl1.FilterFactorTypeGE = false;
                this.m_oChartCtrl1.FilterFactorTypeGP = false;
                FactorType eFType = this.EFType;
                if (eFType != FactorType.HK)
                {
                    if (eFType == FactorType.SK)
                    {
                        goto Label_0102;
                    }
                    if (eFType == FactorType.BK)
                    {
                        this.m_oChartCtrl1.FilterFactorTypeBK = true;
                        //todo
                        //this.Interpretation = oWorkingProject.CurrentPeriod.InterpretationQQSBarChartBK;
                    }
                }
                else
                {
                    this.m_oChartCtrl1.FilterFactorTypeHK = true;
                    //todo
                    //this.Interpretation = oWorkingProject.CurrentPeriod.InterpretationQQSBarChartHK;
                }
                goto Label_011F;
            Label_0102:
                this.m_oChartCtrl1.FilterFactorTypeSK = true;
                //todo
                //this.Interpretation = oWorkingProject.CurrentPeriod.InterpretationQQSBarChartSK;
            Label_011F:
                flag = this.m_oChartCtrl1.CreateChart();
                riNumberOfElements = this.m_oChartCtrl1.NumberOfElements;
            }
            catch (Exception exception)
            {
                flag = false;
                //rsErr = "Fehler in BarChartSubReport.CreateReport: " + exception.Message;
                Log.LogException(exception);
            }
            return flag;
        }      

        public FactorType EFType
        {
            get
            {
                return this.m_eEFType;
            }
            set
            {
                this.m_eEFType = value;
            }
        }

        public string Interpretation
        {
            get
            {
                return this.m_sInterpretation;
            }
            set
            {
                this.m_sInterpretation = value;
                this.cellInterpretation.Text = ReportTemplate.GetInterpretationString(this.m_sInterpretation);
            }
        }
    }
}
